import React from 'react'
import ReactDOM from 'react-dom'

function formatName(user) {
  return user.firstName + '-----' + user.lastName
}

function getGreeting(user) {
  if (user) {
    return <h1>hello, { formatName(user)}!</h1>
  }
  return <h1>hello, Stranger.</h1>
}

const user = {
  firstName: '张三',
  lastName: '李四'
}

ReactDOM.render(
  getGreeting(user),
  document.getElementById('root')
)